<?php
include_once "xAP-functions/webincludes.php";

// build search list
$idraw=$_GET["id"];
//echo $idraw;
$arid=explode("---",$idraw);
$sourceid=intval($arid[0]);
unset($arid[0]);
if ($sourceid>0){

	$path=implode(DIRECTORY_SEPARATOR,$arid);
	
	$sql="select Location from xAP_Pictures_Source where SourceID=".$sourceid;
	$results=dbquery($sql);
	
	$picpath=$results[0]["Location"].DIRECTORY_SEPARATOR.$path;
	$picpath=str_replace("\\'","'",$picpath);
	$picpath=str_replace("\\","\\\\",$picpath);
	//clear trailing slashes
	if(substr($picpath,-2)=="\\\\"){$picpath=substr($picpath,0,strlen($picpath)-2);}
	if(substr($picpath,-1)=="/"){$picpath=substr($picpath,0,strlen($picpath)-1);}
	
	$sql="SELECT FullLocation,SourceID,ItemID FROM xap_pictures_item where fullfolder='".dbesc($picpath)."'";
	$results=dbquery($sql);
	//echo $sql;
	foreach($results as $v){
		echo "<img src='image.php?id=".$v["ItemID"]."&type=1' width=160 height=120>";
	}
}
?>